The present invention relates to a line segment detector which detects character and diagram line segments from input images or line segments of the contour portions of natural images.
It is important in the fields of coding, image processing, and the like to extract character and diagram line segments from input images or line segments of the contour portions of natural images. A conventional line segment detector for detecting line segments from input images is disclosed in Japanese Patent Laid-Open No. 8-237475 (reference 1).
The line segment detector disclosed in reference 1 includes a dot feature amount extraction function of extracting the feature amount of a dot area, in an Mxc3x97N window containing a target pixel in an image, by logical operation and detecting whether the target pixel is a dot candidate pixel or not, a maximum signal level difference detection function of obtaining the difference between the maximum and minimum levels of an image signal in the window, an edge detection function of converting the image signal into a P-value and comparing the P-value signal with a predetermined signal pattern to detect whether the target pixel is an edge image or not, a ratio counting function of counting the ratio of pixels included in the uppermost level if the target pixel is at the uppermost level, and counting the ratio of pixels included in the lowermost level if the target pixel is at the lowermost level, and a change count counting function of counting the sum of the change count of level from the uppermost level to the lowermost level and the change count of level from the lowermost level to the uppermost level. This detector then identifies dots, characters, and photographs in accordance with these count results.
According to the conventional line segment detector, however, when a color still image made up of dots is processed, a dot is erroneously detected as a line segment. This is because, since the conventional line segment detection scheme detects a line segment by differentiation, the differentiation responds to point images constituting a dot image to result in a detection error. A method of detecting line segments by using the Hough transform has also been proposed. In this method, however, since positions where the differential values are large are traced, desired performance cannot be obtained if positions where the differential values are large occur randomly as in a dot image.
To solve the above problem of error detection, a method of performing differentiation after a dot period is eliminated through a low-pass filter is available. In this method, although the differential values at dots are reduced, the differential values at thin line segments are also reduced. For this reason, a threshold for separating dots from line segments cannot be selected, and thin line segments cannot be detected.
It is an object of the present invention to provide a line segment detector which can correctly detect line segments even in an image having both dots and line segments without responding to any dots.
In order to achieve the above object, according to the present invention, there is provided a line segment detector comprising first weighted average 1S means for calculating a weighted average of pixel values in a first detection window set in a first neighboring area of a target pixel in an input image, second weighted average means for calculating a weighted average of pixel values in a second detection window set in a second neighboring area point symmetrical with the first neighboring area with respect to the target pixel, differentiating means for calculating an absolute value of a difference between outputs from the first and second weighted average means, dot detecting means for calculating an average of absolute values of differential values between pixels in a direction of at least one of a vertical line, horizontal line, left-to-right downward slanting line, and left-to-right upward slanting line within a third detection window set in an area containing the target pixel, and comparing means for, if a subtraction result obtained by subtracting an output from the dot detecting means from an output from the differentiating means is larger than a predetermined threshold, determining that a portion near the target pixel is one of a vertical line image, horizontal line image, left-to-right downward slanting line image, and left-to-right upward slanting line image.